package com.wgzx.modbus.message;

import com.wgzx.modbus.entity.ModbusRsp;

import java.util.concurrent.CompletableFuture;

public class FutureMsgListener implements MsgListener<ModbusRsp> {

    private CompletableFuture future;

    public FutureMsgListener(CompletableFuture future) {
        this.future = future;
    }

    @Override
    public void onSuccess(ModbusRsp rsp) {
        this.future.complete(rsp);
    }

    @Override
    public void onError(Throwable t) {
        this.future.completeExceptionally(t);
    }
}
